package edu.java.lectures.lec03;

import sun.java2d.pipe.AlphaPaintPipe;

public class SuperCoolFruit {

    // --- Enum ----------------------------------------------------------------

    public enum Sort {
	APPLE,

	PEAR,

	PEACH;
    }

    public enum Sort2 {
	APPLE;
    }

    // NOT POSSIBLE:
    // enum HackSort extends Sort {
    // APPLE = PEAR;
    // }

    // --- Instance Variables --------------------------------------------------

    private Sort sort; // null / Sort.APPLE / PEAR / PEACH / NO -> GRAPE

    // --- COnstructors --------------------------------------------------------

    public SuperCoolFruit(Sort sort) {
	this.sort = sort;
    }

    // --- Methods -------------------------------------------------------------

    public static void main(String[] args) {
	SuperCoolFruit fruit = new SuperCoolFruit(Sort.PEAR);

	System.out.println(Sort.APPLE == Sort.valueOf("APPLE"));

	for (Sort sort : Sort.values()) {
	    System.out.println(sort);
	}

	Sort fruitSort = fruit.getSort();
	switch (fruitSort) {
	case APPLE:
	    System.out.println(Sort.APPLE);
	    break;
	case PEACH:
	    System.out.println(Sort.PEACH);
	    break;
	case PEAR:
	    System.out.println(Sort.PEAR);
	    break;
	default:
	    throw new IllegalStateException("Unsupported type: " + fruitSort);
	}
    }

    public Sort getSort() {
	return sort;
    }

    public void setSort(Sort sort) {
	this.sort = sort;
    }

}
